/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2021-01-31 10:16:11
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2024-03-04 11:29:06
 * @FilePath: /ams_kt_front/src/api/certifiedProperty/propertyContract.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsContractProperty';
// 预警合同_分页查询
export const warningPage = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: api + '/warningPage',
    params,
  });
// 合同弃审
export const unapproved = (id?: any) =>
  defHttp.post<BasicFetchResult<any>>({
    url: api + '/unapproved/' + id,
  });
//终止合同
export const termination = (params?: any) =>
  defHttp.post({ url: api + '/termination', params });
// 合同变更版本前进行校验
export const checkChangeVersions = (id?: any) =>
  defHttp.get({ url: api + '/checkChangeVersions/' + id });

//退场单_不分页列表查询
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });

// 根据变更记录DTO生成应收计划
export const getByChangeRecordLeased = (params?: any) =>
  defHttp.post({ url: api + '/getByChangeRecordLeased', params });
// 根据合同ID,查询应收计划
export const getByContractId = (id?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/getByContractId/' + id });
/// 根据合同生成应收计划
export const getByContract = (params?: any) =>
  defHttp.post({ url: api + '/getByContract', params });
// 合同主要信息_暂存修改
export const stagingEdit = (params?: any) =>
  defHttp.post({ url: api + '/stagingEdit', params });
// 合同_变更版本
export const updateVersions = (params?: any) =>
  defHttp.post({ url: api + '/updateVersions', params });
//合同主要信息_暂存
export const staging = (params?: any) =>
  defHttp.post({ url: api + '/staging', params });
// 物业合同查单条
export const getDetail = (id?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/detail/' + id });
/**
 * 查询物业合同管理分页
 * @author 1
 * @date 2021-01-31 09:44:35
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
export const assetList = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 添加物业合同管理
 * @author 1
 * @date 2021-01-31 09:44:35
 */
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
/**
 * 修改物业合同管理
 * @author 1
 * @date 2021-01-31 09:44:35
 */
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });

/**
 * 删除物业合同管理
 * @author 1
 * @date 2021-01-31 09:44:35
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出物业合同管理
 * @author 1
 * @date 2021-01-31 09:44:35
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true },
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
